﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class MasterPage : System.Web.UI.MasterPage
{
    SoLienLacDataContext db = new SoLienLacDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Username"].ToString() != null && Session.Contents["TrangThai"].ToString() == "DaDangNhap")
        {
            var c = from p in db.Admins select p;
            foreach (var q in c)
            {

                if (Session["Username"].ToString() == q.TenDangNhap && Session["Username"].ToString() == "admin")
                {

                    lbt.Visible = true;
                    span1.Visible = true;
                    lblDangNhap.Text = Session["Username"].ToString();
                    DSHS.HRef = "#";
                    QLLoiVP.HRef = "#";
                    NhapDiem.HRef = "#";
                    BangDiem.HRef = "#";
                    KQTheoKy.HRef = "#";
                    THKQ.HRef = "#";
                    DGHK.HRef = "#";
                }
                if (Session["Username"].ToString() == q.TenDangNhap && Session["Username"].ToString() != "admin")
                {
                    lbt.Visible = true;
                    span1.Visible = true;
                    lblDangNhap.Text = Session["Username"].ToString();
                    DSHS.HRef = "#";
                    QLLoiVP.HRef = "#";
                    NhapDiem.HRef = "#";
                    BangDiem.HRef = "#";
                    KQTheoKy.HRef = "#";
                    THKQ.HRef = "#";
                    TaoTK.HRef = "#";
                    DGHK.HRef = "#";

                }
            }
            var c1 = from p in db.CanBoGiaoViens select new { p.MaCanBoGV, p.MatKhau, p.TenCanBo };
            foreach (var a in c1)
            {
                if (Session["Username"].ToString() == a.MaCanBoGV)
                {
                    lbt.Visible = true;
                    span1.Visible = true;
                    lblDangNhap.Text = Session["TenCanBo"].ToString();
                    var r = from p in db.Lop_Bans select new { p.MaCanBoGV, p.TrangThaiGiangDay };
                    foreach (var r1 in r)
                    {
                        if (Session["Username"] == r1 && r1.TrangThaiGiangDay == true)
                        {
                            TaoTK.HRef = "#";
                            QLBan_Lop_Mon.HRef = "#";
                            QLNH_KH.HRef = "#";
                            NhapDiem.HRef = "#";
                            NhapGVCN.HRef = "#";
                            NhapTTGV.HRef = "#";
                            QlLop_HS.HRef = "#";
                            TBM.HRef = "#";
                        }
                    }
                    var f = from p in db.GiaoVien_Lop_Mons select new { p.MaCanBoGV, p.TrangThaiGiangDay };
                    foreach (var f1 in f)
                    {
                        if (Session["Username"] == f1.MaCanBoGV && f1.TrangThaiGiangDay == true)
                        {
                            DSHS.HRef = "#";
                            QLLoiVP.HRef = "#";
                            KQTheoKy.HRef = "#";
                            THKQ.HRef = "#";
                            TaoTK.HRef = "#";
                            NhapGVCN.HRef = "#";
                            NhapTTGV.HRef = "#";
                            QlLop_HS.HRef = "#";
                            TBM.HRef = "#";
                            DGHK.HRef = "#";
                            QLBan_Lop_Mon.HRef = "#";
                        }
                    }
                }
            }
        }
        else
        {
            if (Session["Username"].ToString() == null && Session.Contents["TrangThai"].ToString() == "ChuaDangNhap")
            {
                Response.Redirect("TrangChu.aspx?url=" + Request.Url.PathAndQuery);
            }
        }
           
    }
    protected void btnDangXuat_Click(object sender, EventArgs e)
    {
       
    }
    protected void lkbDangXuat_Click(object sender, EventArgs e)
    {
       
    }
    protected void lbt_Click(object sender, EventArgs e)
    {

    }
}
